{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
    {load href="__CSS__video-js.min.css"}
    {load href="__JS__video.min.js"}
<style>
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
        margin-left: 3.333px;
    }

    .search {
        margin-bottom: 0px !important;
    }

    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <!-- <div class="fixed-table-toolbar loadClick">
                        <a class="btn btn-default btn-outline {present name='state'}{eq name='state' value='1'}asdlkjasd{/eq}{else /}asdlkjasd{/present}" href="{:url('users',['state'=>1])}">正常</a>
                        <a class="btn btn-default btn-outline {present name='state'}{eq name='state' value='0'}asdlkjasd{/eq}{/present}" href="{:url('users',['state'=>0])}">自主退出</a>
                        <a class="btn btn-default btn-outline {present name='state'}{eq name='state' value='-1'}asdlkjasd{/eq}{/present}" href="{:url('users',['state'=>-1])}">系统移出</a>
                    </div> -->
                    <div class="fixed-table-toolbar loadClick">
                        <form  method="get" action="">
                            <div class="pull-left search">
                                <div class="columns columns-right btn-group pull-left" >
                                    <div class="columns columns-right btn-group pull-left" >
                                        <select class="form-control" name="config_id">
                                            <option value="" ></option>
                                            {volist name="configs" id="config"}
                                            <option value="{$config.id}" {eq name="config_id" value="$config.id" }selected{/eq}>{$config.name}</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>
                                {php}
                                if(input('?param.search_name')){
                                {/php}
                                <div class="pull-right search">
                                    <a class="btn btn-w-m btn-link" href="{:url('users')}">返回管理</a>
                                </div>{php}
                                }
                                {/php}
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" id="search-btn" type="submit">搜索</button>
                                </div>
                                <div class="pull-right search">
                                    <input class="form-control input-outline" id="filter" type="text"
                                           {php}
                                           if(input('?param.search_name')){
                                    if(input('param.search_name')){
                                    echo "value='".input('search_name')."'";
                                    }
                                    }
                                    {/php}
                                    name="search_name" placeholder="输入用户ID搜索">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="fixed-table-toolbar">
                        <span style="float:right">
                        <a class="btn btn-default btn-outline {present name='order'}{eq name='order' value='1'}asdlkjasd{/eq}{/present}"
                           href="{:url('users',['order'=>'1'])}">报名时间正序</a>
                        <a class="btn btn-default btn-outline {present name='order'}{eq name='order' value='2'}asdlkjasd{/eq}{/present}"
                           href="{:url('users',['order'=>'2'])}">报名时间倒序</a>
                        <a class="btn btn-default btn-outline {present name='order'}{eq name='order' value='3'}asdlkjasd{/eq}{/present}"
                           href="{:url('users',['order'=>'3'])}">评分人数倒序</a>
                        </span>
                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">
                            <table data-toggle="table">
                                <thead>
                                <tr>
                                    <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                                    <th data-align="center">ID</th>
                                    <th data-align="center">活动名称</th>
                                    <th data-align="center">头像</th>
                                    <th data-align="center">用户</th>
                                    <th>平均分</th>
                                    <th>打分人数</th>
                                    <th data-align="center">报名时间</th>
                                    <th data-align="center">最后打分时间</th>
                                    <th data-align="center">状态</th>
                                    <th data-align="center">管理</th>

                                </tr>
                                </thead>
                                <tbody id="form">
                                {volist name="data" id="v" key="k"}
                                <tr id="id{$v.id}" class="class">
                                    <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                                    <td id="id">{$v.id}</td>
                                    <td id="id">{$v.config_name}</td>
                                    {php}
                                    $user = _user($v['user_id']);
                                    {/php}
                                    <td>
                                        <a href="{:strpos($user.head_100, 'http')===false?'__ROOT__':''}{$user.head_100}" target="_blank">
                                            <img style="width:60px;height:60px;" src="{:strpos($user.head_100, 'http')===false?'__ROOT__':''}{$user.head_100}"/>
                                        </a>
                                    </td>
                                    <td >
                                        <a onclick="member('{$v.user_id}')" style="color:#40BCF7">{$user['name']}</a><br/>({$user['id']})({$user['sex']})<br />({$user['age']}岁)
                                    </td>
                                    <td>
                                        <?php echo $v['score_avg']; ?>
                                    </td>
                                    <td>
                                        <?php echo $v['scoring_count']; ?>
                                    </td>
                                    <td>
                                        <span {php}if(date('Y-m-d')==date('Y-m-d',strtotime($v['create_time'])))echo 'style="color: #ed5565"';{/php}>{$v.create_time}</span>
                                    </td>
                                    <td>
                                        <span {php}if(date('Y-m-d')==date('Y-m-d',strtotime($v['update_time'])))echo 'style="color: #ed5565"';{/php}>{$v.update_time}</span>
                                    </td>
                                    <td id="hide{$v.id}">{if condition="$v.state eq '0'"}<span style="color: #ed5565">用户自主退出</span>{elseif condition="$v.state eq '1'" /}<span style="color: #1ab394">正 常</span>{elseif condition="$v.state eq '-1'" /}<span style="color: #ed5565">系统移出</span> {$v.reason}{/if}</td>
                                    <td>
                                        <div class="btn-group">
                                            <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                                            </div>
                                            <ul class="dropdown-menu">
                                                <li><a onClick="scoring({$v.user_id},{$v.config_id})"><span>打分记录</span></a></li>
                                                {switch name="$v.state"}
                                                {case value="-1"}
                                                <li><a onClick="shenhe({$v.id},'1')"><span style="color: #1ab394; ">恢复</span></a></li>
                                                {/case}
                                                {case value="0"}
                                                {/case}
                                                {case value="1"}
                                                <li><a onClick="shenhe({$v.id},'-1')"><span style="color: #ed5565; ">移出</span></a></li>
                                                {/case}
                                                {/switch}
                                            </ul>
                                        </div>
                                    </td>

                                </tr>
                                {/volist}
                                </tbody>

                            </table>
                        </form>
                    </div>
                </div>
            </div>
            <hr>
            <div class="row row-lg">
                <div class="col-sm-6 pages">{$page}</div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    $(document).ready(function(){
    });
    function del(id){
        swal_del(id,"{:url('userdel')}")
    }
    function alla(types){
        var all=$(".form-horizontal").serialize();
        var alls=$(".form-horizontal").serializeArray();
        console.log(JSON.stringify(alls))

        ajaxFun("post",'{:url('shenheAll')}?type='+types,all,'json',function(ret){

            if(ret){
                var text
                switch(types)
                {
                    case -1:
                        text = '<span class="btn btn-primary btn-xs" style="background-color: #414141;border-color:#414141">系统移出</span>';
                        break;
                    case 1:
                        text = '<span class="btn btn-primary btn-xs">正 常</span>';
                        break;
                }
                for(var i=0;i<alls.length;i++){
                    if(types=='del'){
                        $('#id'+alls[i]['value']).remove();
                    }else{
                        $('#hide'+alls[i]['value']).html(text);
                    }
                }
                layer.closeAll('loading'); 
                swal_msg('操作成功')
            }
        })

    }
    function scoring(touser_id, config_id) {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['50%', '80%'],
                type: 2,
                content: `{:url("scoring")}?touser_id=${touser_id}&config_id=${config_id}`
            });
        });
    }
    var reasons = JSON.parse('{$rejects}');
    var reasonHtml = '';
    reasons.forEach(item=>{
        reasonHtml += `<div style="margin:5px 10px;cursor: pointer;" onclick="inputEnter('${item.reason}')">${item.reason}</div>`
    })
    function inputEnter(v) {
        $('#extraInput').val(v)
    }
  function shenhe(id,value){
    if(value == -1){
        var extraContent = `<div>
                                <textarea class="layui-layer-input" id="extraInput"></textarea>
                                <div style="display:flex;flex-wrap:wrap;padding-top:20px;">${reasonHtml}</div>
                            </div>`;

      layer.prompt({
        formType: 2,
        value: '',
        title: '请输入拒绝原因',
        content: extraContent, // 额外的内容
        area: ['500px', '400px'] //自定义文本域宽高
      }, function(reason, index, elem){
        shenheAction(id, value, reason)
        layer.close(index);
      });
    } else {
      shenheAction(id,value)
    }
  }
  function shenheAction(id,value,reason='') {
      ajaxFun("post","{:url('authadd')}",{id:id,shenhe:value,reason},'json',function(ret){
          if(ret){
              if(ret.ret){
                  layer.msg(ret.ret)
                  window.location.reload()
              }else{
                  layer.msg(ret.err)
              }
          }else{
              swal_msg("错误",ret,"error");
          }
      })
  }

    function member(id)
    {
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
                title :'预览',
                area: ['100%', '100%'],
                type: 2,
                content: '{:url("member/index")}?search=id&name='+id
            });
        });
    }

</script>
 